<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/jquery-3.4.1min.js"></script>
		<link rel="stylesheet" href="../css/bootstrap.min.css">
		<script src="../js/popper.min.js"></script>
		<script src="../js/bootstrap.min.js"></script>
		<script type="text/javascript">
			$(function () {
				$("#buyTicket").click(function () {
					//$("#inlineFormCustomSelect").val()
					let str = $("#inlineFormCustomSelect").val();
					let params = str.match(/\w+=[^,]+/g).map(param => param.split('='));
					let obj = {};
					params.forEach(param => obj[param[0]] = param[1]);
					let jsonStr = JSON.stringify(obj);
					console.log(jsonStr);
					let a = JSON.parse(jsonStr)
					console.log(a)
					var num = $('#NumVal').val()
					$.ajax({
						url:"/order/buyTicket",
						data:{"tid":a.tid,"tmoney":a.tmoney,"tnum":a.tnum,"number":num},
						type:"post",
						dateType:"json",
						success:function (data){
							console.log(data)
							if (data.code==200){
								$("#eb").empty();
								$("#eb").append("<a href='/order/goOK' class='card-link'>购买成功！点击跳转首页...</a>");
							}else{
								alert(data.msg);
							}
						}
					})
				})
			})
		</script>
	</head>
	<body>
		<div class="container">
			<div class="card mb-3" id="showContain">
			  <img src="${ex1.epic}" class="card-img-top" alt="...">
			  <div class="card-body" id="eb">
			    <h5 class="card-title">${ex1.etitle}</h5>
			    <p class="card-text">${ex1.ebody}</p>
			    <p class="card-text"><small class="text-muted">${ex1.ebegin}到${ex1.etime}</small></p>
				  数量：<input type="number" id="NumVal" value="1"/>
				<form>
				  <div class="form-row align-items-center">
				    <div class="col-auto my-1">
				      <label class="mr-sm-2 sr-only" for="inlineFormCustomSelect">Preference</label>
				      <select class="custom-select mr-sm-2" id="inlineFormCustomSelect" name="eid">
						<c:forEach items="${tick1}" var="tick" varStatus="status">
							<option value="${tick}">
									<p>
											${tick.t_start_time}至${tick.t_end_time}
<%--										<fmt:formatDate value="${tick.t_start_time}" pattern="yyyy-MM-dd HH:mm:ss"/>至<fmt:formatDate value="${tick.t_end_time}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
									<p>/余票：${tick.tnum}</p>
									<p>/金额：${tick.tmoney}</p>
							</option>
						</c:forEach>
				      </select>

				    </div>
				    <div class="col-auto my-1">
				      <button type="button" id="buyTicket" class="btn btn-primary">购买</button>
				    </div>
				  </div>
				</form>
			  </div>
			</div>
<%--			assess1--%>
			<c:forEach items="${assess1}" var="assess" varStatus="status">
				<div class="card" style="margin-top: 20px">
					<div class="card-header">
						${assess.user.uname}
					</div>
					<div class="card-body">
						<blockquote class="blockquote mb-0">
							<p>${assess.acontent}</p>
							<footer class="blockquote-footer">
								<div style="text-align: right">
									<cite title="Source Title"><fmt:formatDate value="${assess.atime}" pattern="yyyy-MM-dd HH:mm:ss"/></cite>
								</div>
							</footer>
						</blockquote>
					</div>
				</div>
			</c:forEach>

		
		
		
	</body>
</html>
